package com.zzsy.carosshopprojects.activitys.home.mainpage.menu.changeshifts;

import android.content.Context;

import com.king.base.util.ToastUtils;
import com.zzsy.carosshopprojects.base.BaseViewMode;
import com.zzsy.carosshopprojects.bean.ChangeShiftsBean;
import com.zzsy.carosshopprojects.network.RequestUtils;
import com.zzsy.carosshopprojects.network.Utils.MyObserver;
import com.zzsy.carosshopprojects.util.DataUtil;

import androidx.lifecycle.MutableLiveData;

public class ChangeShiftsMode extends BaseViewMode {
    private MutableLiveData<ChangeShiftsBean> liveData;

    public void getData(Context context, String page, boolean isShowDialog) {
        if (DataUtil.getInstance().getCustomerType().equals("1")) {//加油员的交接历史记录
            RequestUtils.HandoverList(context, page, DataUtil.getInstance().getTerminalId(), DataUtil.getInstance().getStoreId(), new MyObserver<ChangeShiftsBean>(context, isShowDialog) {
                @Override
                public void onSuccess(ChangeShiftsBean bean) {
                    liveData.postValue(bean);
                }

                @Override
                public void onFailure(Throwable e, String errorMsg, int code) {
                    ToastUtils.showToast(context.getApplicationContext(), errorMsg);
                }
            });
        } else if (DataUtil.getInstance().getCustomerType().equals("2")) {//吧台的交接历史记录
            RequestUtils.RechargeHandoverList(context, page, DataUtil.getInstance().getTerminalId(), DataUtil.getInstance().getStoreId(), new MyObserver<ChangeShiftsBean>(context, isShowDialog) {
                @Override
                public void onSuccess(ChangeShiftsBean bean) {
                    liveData.postValue(bean);
                }

                @Override
                public void onFailure(Throwable e, String errorMsg, int code) {
                    ToastUtils.showToast(context.getApplicationContext(), errorMsg);
                }
            });
        }


    }


    public MutableLiveData<ChangeShiftsBean> getLiveData() {
        if (liveData == null)
            liveData = new MutableLiveData<>();
        return liveData;
    }


}
